{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# The Py-ART Radar object and indexing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# The Py-ART radar object has functions and attributes that allow for a more\n",
    "# in depth look of the data and the radar object."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "## You are using the Python ARM Radar Toolkit (Py-ART), an open source\n",
      "## library for working with weather radar data. Py-ART is partly\n",
      "## supported by the U.S. Department of Energy as part of the Atmospheric\n",
      "## Radiation Measurement (ARM) Climate Research Facility, an Office of\n",
      "## Science user facility.\n",
      "##\n",
      "## If you use this software to prepare a publication, please cite:\n",
      "##\n",
      "##     JJ Helmus and SM Collis, JORS 2016, doi: 10.5334/jors.119\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# Import needed modules\n",
    "import numpy as np\n",
    "import pyart"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load the radar file\n",
    "radar = pyart.io.read(\"KATX20130717_195021_V06\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "altitude:\n",
      "\tdata: <ndarray of type: float64 and shape: (1,)>\n",
      "\tlong_name: Altitude\n",
      "\tstandard_name: Altitude\n",
      "\tunits: meters\n",
      "\tpositive: up\n",
      "altitude_agl: None\n",
      "antenna_transition: None\n",
      "azimuth:\n",
      "\tdata: <ndarray of type: float64 and shape: (7200,)>\n",
      "\tunits: degrees\n",
      "\tstandard_name: beam_azimuth_angle\n",
      "\tlong_name: azimuth_angle_from_true_north\n",
      "\taxis: radial_azimuth_coordinate\n",
      "\tcomment: Azimuth of antenna relative to true north\n",
      "elevation:\n",
      "\tdata: <ndarray of type: float32 and shape: (7200,)>\n",
      "\tunits: degrees\n",
      "\tstandard_name: beam_elevation_angle\n",
      "\tlong_name: elevation_angle_from_horizontal_plane\n",
      "\taxis: radial_elevation_coordinate\n",
      "\tcomment: Elevation of antenna relative to the horizontal plane\n",
      "fields:\n",
      "\tdifferential_reflectivity:\n",
      "\t\tdata: <ndarray of type: float32 and shape: (7200, 1832)>\n",
      "\t\tunits: dB\n",
      "\t\tstandard_name: log_differential_reflectivity_hv\n",
      "\t\tlong_name: log_differential_reflectivity_hv\n",
      "\t\tvalid_max: 7.9375\n",
      "\t\tvalid_min: -7.875\n",
      "\t\tcoordinates: elevation azimuth range\n",
      "\t\t_FillValue: -9999.0\n",
      "\tdifferential_phase:\n",
      "\t\tdata: <ndarray of type: float32 and shape: (7200, 1832)>\n",
      "\t\tunits: degrees\n",
      "\t\tstandard_name: differential_phase_hv\n",
      "\t\tlong_name: differential_phase_hv\n",
      "\t\tvalid_max: 360.0\n",
      "\t\tvalid_min: 0.0\n",
      "\t\tcoordinates: elevation azimuth range\n",
      "\t\t_FillValue: -9999.0\n",
      "\treflectivity:\n",
      "\t\tdata: <ndarray of type: float32 and shape: (7200, 1832)>\n",
      "\t\tunits: dBZ\n",
      "\t\tstandard_name: equivalent_reflectivity_factor\n",
      "\t\tlong_name: Reflectivity\n",
      "\t\tvalid_max: 94.5\n",
      "\t\tvalid_min: -32.0\n",
      "\t\tcoordinates: elevation azimuth range\n",
      "\t\t_FillValue: -9999.0\n",
      "\tcross_correlation_ratio:\n",
      "\t\tdata: <ndarray of type: float32 and shape: (7200, 1832)>\n",
      "\t\tunits: ratio\n",
      "\t\tstandard_name: cross_correlation_ratio_hv\n",
      "\t\tlong_name: Cross correlation_ratio (RHOHV)\n",
      "\t\tvalid_max: 1.0\n",
      "\t\tvalid_min: 0.0\n",
      "\t\tcoordinates: elevation azimuth range\n",
      "\t\t_FillValue: -9999.0\n",
      "\tspectrum_width:\n",
      "\t\tdata: <ndarray of type: float32 and shape: (7200, 1832)>\n",
      "\t\tunits: meters_per_second\n",
      "\t\tstandard_name: doppler_spectrum_width\n",
      "\t\tlong_name: Spectrum Width\n",
      "\t\tvalid_max: 63.0\n",
      "\t\tvalid_min: -63.5\n",
      "\t\tcoordinates: elevation azimuth range\n",
      "\t\t_FillValue: -9999.0\n",
      "\tvelocity:\n",
      "\t\tdata: <ndarray of type: float32 and shape: (7200, 1832)>\n",
      "\t\tunits: meters_per_second\n",
      "\t\tstandard_name: radial_velocity_of_scatterers_away_from_instrument\n",
      "\t\tlong_name: Mean doppler Velocity\n",
      "\t\tvalid_max: 95.0\n",
      "\t\tvalid_min: -95.0\n",
      "\t\tcoordinates: elevation azimuth range\n",
      "\t\t_FillValue: -9999.0\n",
      "fixed_angle:\n",
      "\tdata: <ndarray of type: float32 and shape: (16,)>\n",
      "\tlong_name: Target angle for sweep\n",
      "\tunits: degrees\n",
      "\tstandard_name: target_fixed_angle\n",
      "instrument_parameters:\n",
      "\tunambiguous_range:\n",
      "\t\tdata: <ndarray of type: float32 and shape: (7200,)>\n",
      "\t\tunits: meters\n",
      "\t\tcomments: Unambiguous range\n",
      "\t\tmeta_group: instrument_parameters\n",
      "\t\tlong_name: Unambiguous range\n",
      "\tnyquist_velocity:\n",
      "\t\tdata: <ndarray of type: float32 and shape: (7200,)>\n",
      "\t\tunits: meters_per_second\n",
      "\t\tcomments: Unambiguous velocity\n",
      "\t\tmeta_group: instrument_parameters\n",
      "\t\tlong_name: Nyquist velocity\n",
      "latitude:\n",
      "\tdata: <ndarray of type: float64 and shape: (1,)>\n",
      "\tlong_name: Latitude\n",
      "\tstandard_name: Latitude\n",
      "\tunits: degrees_north\n",
      "longitude:\n",
      "\tdata: <ndarray of type: float64 and shape: (1,)>\n",
      "\tlong_name: Longitude\n",
      "\tstandard_name: Longitude\n",
      "\tunits: degrees_east\n",
      "nsweeps: 16\n",
      "ngates: 1832\n",
      "nrays: 7200\n",
      "radar_calibration: None\n",
      "range:\n",
      "\tdata: <ndarray of type: float32 and shape: (1832,)>\n",
      "\tunits: meters\n",
      "\tstandard_name: projection_range_coordinate\n",
      "\tlong_name: range_to_measurement_volume\n",
      "\taxis: radial_range_coordinate\n",
      "\tspacing_is_constant: true\n",
      "\tcomment: Coordinate variable for range. Range to center of each bin.\n",
      "\tmeters_to_center_of_first_gate: 2125.0\n",
      "\tmeters_between_gates: 250.0\n",
      "scan_rate: None\n",
      "scan_type: ppi\n",
      "sweep_end_ray_index:\n",
      "\tdata: <ndarray of type: int32 and shape: (16,)>\n",
      "\tlong_name: Index of last ray in sweep, 0-based\n",
      "\tunits: count\n",
      "sweep_mode:\n",
      "\tdata: <ndarray of type: |S20 and shape: (16,)>\n",
      "\tunits: unitless\n",
      "\tstandard_name: sweep_mode\n",
      "\tlong_name: Sweep mode\n",
      "\tcomment: Options are: \"sector\", \"coplane\", \"rhi\", \"vertical_pointing\", \"idle\", \"azimuth_surveillance\", \"elevation_surveillance\", \"sunscan\", \"pointing\", \"manual_ppi\", \"manual_rhi\"\n",
      "sweep_number:\n",
      "\tdata: <ndarray of type: int32 and shape: (16,)>\n",
      "\tunits: count\n",
      "\tstandard_name: sweep_number\n",
      "\tlong_name: Sweep number\n",
      "sweep_start_ray_index:\n",
      "\tdata: <ndarray of type: int32 and shape: (16,)>\n",
      "\tlong_name: Index of first ray in sweep, 0-based\n",
      "\tunits: count\n",
      "target_scan_rate: None\n",
      "time:\n",
      "\tdata: <ndarray of type: float64 and shape: (7200,)>\n",
      "\tunits: seconds since 2013-07-17T19:50:21Z\n",
      "\tstandard_name: time\n",
      "\tlong_name: time_in_seconds_since_volume_start\n",
      "\tcalendar: gregorian\n",
      "\tcomment: Coordinate variable for time. Time at the center of each ray, in fractional seconds since the global variable time_coverage_start\n",
      "metadata:\n",
      "\tConventions: CF/Radial instrument_parameters\n",
      "\tversion: 1.3\n",
      "\ttitle: \n",
      "\tinstitution: \n",
      "\treferences: \n",
      "\tsource: \n",
      "\thistory: \n",
      "\tcomment: \n",
      "\tinstrument_name: KATX\n",
      "\toriginal_container: NEXRAD Level II\n",
      "\tvcp_pattern: 11\n"
     ]
    }
   ],
   "source": [
    "# For a detailed print of the Py-ART radar object, use radar.info()\n",
    "radar.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'units': 'degrees',\n",
       " 'standard_name': 'beam_elevation_angle',\n",
       " 'long_name': 'elevation_angle_from_horizontal_plane',\n",
       " 'axis': 'radial_elevation_coordinate',\n",
       " 'comment': 'Elevation of antenna relative to the horizontal plane',\n",
       " 'data': array([ 0.7470703,  0.7196045,  0.6893921, ..., 19.511719 , 19.511719 ,\n",
       "        19.511719 ], dtype=float32)}"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Let's view the elevation parameter. Py-ART stores all fields as 2D masked arrays\n",
    "# of dimensions (number of rays) x (number of gates). Therefore, as the elevation can change with\n",
    "# each ray, the data in the elevation array is a 1D array of dimension (number of rays)\n",
    "radar.elevation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375\n",
      " 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375 0.52734375]\n"
     ]
    }
   ],
   "source": [
    "# If we just want the elevations of one sweep, we can use the get_slice() function\n",
    "# of the Radar object to just get the elevations from one slice.\n",
    "sweep_1 = radar.get_slice(1)\n",
    "print(radar.elevation['data'][sweep_1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'units': 'dBZ',\n",
       " 'standard_name': 'equivalent_reflectivity_factor',\n",
       " 'long_name': 'Reflectivity',\n",
       " 'valid_max': 94.5,\n",
       " 'valid_min': -32.0,\n",
       " 'coordinates': 'elevation azimuth range',\n",
       " '_FillValue': -9999.0,\n",
       " 'data': masked_array(\n",
       "   data=[[10.5, 7.5, --, ..., --, --, --],\n",
       "         [--, --, --, ..., --, --, --],\n",
       "         [9.5, --, --, ..., --, --, --],\n",
       "         ...,\n",
       "         [-10.5, -15.0, -9.5, ..., --, --, --],\n",
       "         [-14.0, -13.5, -13.5, ..., --, --, --],\n",
       "         [-11.0, -15.0, 0.5, ..., --, --, --]],\n",
       "   mask=[[False, False,  True, ...,  True,  True,  True],\n",
       "         [ True,  True,  True, ...,  True,  True,  True],\n",
       "         [False,  True,  True, ...,  True,  True,  True],\n",
       "         ...,\n",
       "         [False, False, False, ...,  True,  True,  True],\n",
       "         [False, False, False, ...,  True,  True,  True],\n",
       "         [False, False, False, ...,  True,  True,  True]],\n",
       "   fill_value=1e+20,\n",
       "   dtype=float32)}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# All of the radar fields are stored in a dictionary called radar.fields. This dictionary\n",
    "# contains entries that correspond to the field names in the file.\n",
    "radar.fields['reflectivity']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "masked_array(\n",
       "  data=[[10.5, 7.5, --, ..., --, --, --],\n",
       "        [--, --, --, ..., --, --, --],\n",
       "        [9.5, --, --, ..., --, --, --],\n",
       "        ...,\n",
       "        [-10.5, -15.0, -9.5, ..., --, --, --],\n",
       "        [-14.0, -13.5, -13.5, ..., --, --, --],\n",
       "        [-11.0, -15.0, 0.5, ..., --, --, --]],\n",
       "  mask=[[False, False,  True, ...,  True,  True,  True],\n",
       "        [ True,  True,  True, ...,  True,  True,  True],\n",
       "        [False,  True,  True, ...,  True,  True,  True],\n",
       "        ...,\n",
       "        [False, False, False, ...,  True,  True,  True],\n",
       "        [False, False, False, ...,  True,  True,  True],\n",
       "        [False, False, False, ...,  True,  True,  True]],\n",
       "  fill_value=1e+20,\n",
       "  dtype=float32)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# This shows entries such as the data itself, coordinates, long name, and units. You can\n",
    "# access the array with the reflectivity data itself using radar.fields['reflectivity']['data'].\n",
    "# This is stored as a 2D masked array with dimensions (number of rays) x (number of gates)\n",
    "radar.fields['reflectivity']['data']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[10.5 7.5 -- ... -- -- --]\n",
      " [-- -- -- ... -- -- --]\n",
      " [9.5 -- -- ... -- -- --]\n",
      " ...\n",
      " [-- 6.0 11.0 ... -- -- --]\n",
      " [-- -- -- ... -- -- --]\n",
      " [-- -- -- ... -- -- --]]\n"
     ]
    }
   ],
   "source": [
    "# If you just want the data from one slice, you can get the indicies for the\n",
    "# slice using radar.get_slice()\n",
    "slice_indices = radar.get_slice(0)\n",
    "print(radar.fields['reflectivity']['data'][slice_indices])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-2.9066728410400056, -3.478547577741713, -6.587792083929423, -6.871031288639269, -10.971692217963673, -11.830616390843327, -12.108188248095756, -12.483419908190385, -12.88976917057903, -11.852766685681688, -12.410455582269897, -12.66444787446138, -12.997862391449566, -13.172098402018502, -13.489752513534416, -13.712565619531706]\n"
     ]
    }
   ],
   "source": [
    "# You can also iterate over each slice by using radar.iter_slice() This example\n",
    "# returns the mean reflectivity of each sweep.\n",
    "reflectivity = [radar.fields['reflectivity']['data'][x].mean() for x in radar.iter_slice()]\n",
    "print(reflectivity)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 8.81,  8.81,  8.81, ..., 32.33, 32.33, 32.33], dtype=float32)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# You can also view the important radar instrument parameters. One commonly used parameter\n",
    "# is the nyquist velocity, which is the maximum magnitude of the velocity the radar is\n",
    "# capable of recording before a phenomena known as aliasing occurs.\n",
    "radar.instrument_parameters['nyquist_velocity']['data']"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
